<?php include './pages/reportMenu.php'; ?>
<div id="viewStock">
	<?php
		if (!isset($_SESSION)) {
			 session_start();
		}
		include("./system/dbconnection.php");
		if($result = mysql_query("SELECT items.itemCode, items.itemName, batches.batchDate, stock.unitPrice, stock.MFD, stock.EXP, stock.stockQuantity, units.unitCode FROM  `stock` INNER JOIN  `items` ON stock.itemCode = items.itemCode INNER JOIN  `batches` ON stock.batchId = batches.batchId INNER JOIN  `units` ON items.itemUnit = units.unitId WHERE stockQuantity != 0")){
			$num = mysql_num_rows($result);
		}else{
			$_SESSION['error'] = "Error occured ";
		}
	?>
	<table border="1" cellpadding="2" class="stockTable dataTable" style="width:100%">
		<thead>
			<tr>
				<th>Item Code</th>
				<th>Item Name</th>
				<th>Batch Date</th>
				<th>Unit Price</th>
				<th>MFD</th>
				<th>EXP</th>
				<th>Quantity</th>
			</tr>
		</thead>
		<tbody>
		<?php
			$i=0;
			while ($i < $num) {
				$f1=mysql_result($result,$i,"itemCode");
				$f2=mysql_result($result,$i,"itemName");
				$f3=mysql_result($result,$i,"batchDate");
				$f4=mysql_result($result,$i,"unitPrice");
				$f5=mysql_result($result,$i,"MFD");
				$f6=mysql_result($result,$i,"EXP");
				$f7=mysql_result($result,$i,"stockQuantity");
				$f8=mysql_result($result,$i,"unitCode");
		?>
			<tr>
				<td><?php echo $f1; ?></td>
				<td><?php echo $f2; ?></td>
				<td><?php echo $f3; ?></td>
				<td><?php echo $f4; ?></td>
				<td><?php echo $f5; ?></td>
				<td><?php echo $f6; ?></td>
				<td><?php echo $f7. '  ' .$f8 ?></td>
			</tr>
		<?php
				$i++;
			}
		?>
		</tbody>
	</table>
</div>